#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from rest_framework import serializers
from .models import Area


class AreaSerializer(serializers.ModelSerializer):
    """省市区序列化器"""

    class Meta:
        model = Area
        fields = ["id", "name"]


class AreaDetailSerializer(serializers.ModelSerializer):
    """省市区详情序列化器,嵌套序列化器"""
    subs = AreaSerializer(many=True)

    class Meta:
        model = Area
        fields = ["id", "name", "subs"]
